<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <title>合伙人账户</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            background: #F8F8F8;
        }

        .head {
            width: 100%;
            height: 115px;
        }

        .box-first {
            width: 90%;
            height: 200px;
            background: #ffffff;
            border-radius: 15px;
            box-shadow: 0px 2px 15px 1px #dcdcdc;
            position: absolute;
            left: calc((100% - 90%)/2);
            top: 55px;
        }

        .box-second {
            position: absolute;
            left: calc((100% - 90%)/2);
            top: 270px;
            width: 90%;
            height: 340px;
            background: #ffffff;
            border-radius: 15px;
            box-shadow: 0px 2px 15px 1px #dcdcdc;
        }

        .box-content {
            display: flex;
            align-items: center;
            padding: 20px;
        }

        .user-img {
            width: 65px;
            height: 65px;
            border-radius: 50%;
            margin-right: 10px;
        }

        .black_img {
            width: 100%;
            height: 85px;
        }

        .card {
            position: relative;
            width: 95%;
            height: 90px;
            border-radius: 15px;
            margin: 0 auto;
        }

        .card-content {
            padding: 2%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: absolute;
            top: 0;
            width: 90%;
            left: calc((95% - 90%)/2);
        }

        .cash {
            color: #434346;
            background-image: linear-gradient(#E3C086, #F8E0BC);
            width: 50px;
            height: 25px;
            line-height: 25px;
            border-radius: 999px;
            text-align: center;
            font-size: 14px;
        }

        .card-bottom {
            padding: 5px 10px 0 10px;
            display: flex;
            align-items: center;
            color: #F1CC96;
            position: absolute;
            top: 45px;
        }

        .box-container {
            padding: 20px;
            display: flex;
            align-items: center;
        }

        .box-record {
            display: flex;
            align-items: center;
        }

        .title {
            width: 2px;
            height: 20px;
            background: #E3C086;
            margin-right: 7px;
        }

        .agent_name {
            font-size: 14px;
            display: inline-block;
            margin-bottom: 35px;
        }

        .subtitle {
            padding: 0 10px 20px 10px;
            display: flex;
            align-items: center;
            justify-content: space-around;
            color: #999999;
            font-size: 15px;
            border-bottom: .5px solid #E5E5E5;
        }

        .scroll-view {
            width: 100%;
            height: 235px;
        }

        .scroll-div {
            width: 100%;
            height: 239px;
            overflow-y: scroll;
        }

        .scroll-content {
            display: flex;
            align-items: center;
            height: 50px;
            justify-content: space-around;
            border-bottom: .5px solid #E5E5E5;
            color: #666666;
            font-size: 13px;
            padding: 0 5px;
        }

        .mask {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: #000;
            opacity: .7;
            z-index: 4
        }

        .input_cash {
            width: 70%;
            z-index: 6;
            position: fixed;
            top: calc((100% - 150px)/2);
            left: calc((100% - 70%)/2);
            background-color: #fff;
        }

        input {
            outline: none;
            margin: 10px auto;
            display: block;
            line-height: 28px;
            font-size: 1rem;
            width: 85%;
            height: 40px;
        }

        .con_sure {
            margin: 20px auto;
            border: 0;
            outline: none;
            color: #434346;
            background-image: linear-gradient(#E3C086, #F8E0BC);
            width: 100px;
            height: 25px;
            line-height: 25px;
            border-radius: 999px;
            text-align: center;
            font-size: 14px;
        }

        .cancel {
            margin: 20px auto;
            border: 0;
            outline: none;
            color: #434346;
            background: rgb(239, 239, 239);
            width: 100px;
            height: 25px;
            line-height: 25px;
            border-radius: 999px;
            text-align: center;
            font-size: 14px;
        }
    </style>
</head>

<body>
    <div class="record">
        <img class="head" src="image/head_black.png">
        <div class="box-first">
            <div class="box-content">
                <img class="user-img" src="image/touxiang.jpg" />
                <text class="agent_name">用户</text>
            </div>
            <div class="card">
                <img class="black_img" src="image/bord.png">
                <div class="card-content">
                    <div style="display: flex; align-items: center;">
                        <div style="margin:0 5px;color:#999999">ID:</div>
                        <text class="id_num" style="color:#999999;"></text>
                    </div>
                    <div class="cash">提现</div>
                </div>
                <div class="card-bottom">
                    <div style="margin:0 5px;">待提现:</div>
                    <text class="rmb" style="font-size:20px; font-weight:600;"></text>
                </div>
            </div>
        </div>
        <div class="box-second">
            <div class="box-container">
                <div class="box-record">
                    <div class="title"></div>
                    <text style="color:#333333;">我的推广记录</text>
                </div>
            </div>
            <div class="subtitle">
                <div>时间</div>
                <div>项目</div>
                <div>佣金</div>
                <div>状态</div>
            </div>
            <div class="scroll-div"></div>
        </div>
        <!-- 弹框 -->
        <div class="mask"></div>
        <div class="input_cash">
            <input type="text" placeholder="请输入提现金额" class="money_input">
            <div style="display: flex; justify-content: space-around;">
                <button class="con_sure">确认</button>
                <button class="cancel">取消</button>
            </div>
        </div>
    </div>
</body>
<script src="js/jquery-3.5.1.min.js"></script>
<script>
    $(() => {
        $('.mask').hide()
        $('.input_cash').hide()
        let uid = getUrldata('Uid')
        let u = navigator.userAgent
        // 判断ios
        let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
        // 判断android
        let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1
        // 表情
        let emotion = /([^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n])|(\s)/g

        //判断微信
        function isWeiXin() {
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                return true // 是微信端
            } else {
                return false
            }
        }

        // 统一弹框
        function info_alert(param) {
            if (isWeiXin()) {
                (() => {
                    window.alert = function (name) {
                        var iframe = document.createElement("IFRAME");
                        iframe.style.display = "none";
                        iframe.setAttribute("src", 'data:text/plain');
                        document.documentElement.appendChild(iframe);
                        window.frames[0].window.alert(name);
                        iframe.parentNode.removeChild(iframe);
                    }
                })()
                alert(param)
                return
            }
            if (isiOS) {
                window.webkit.messageHandlers.showAlert.postMessage(param)
                return
            }
            if (isAndroid) {
                window.TiantianCharge_Android.showAlert(param)
                return
            }
        }

        $.ajax({
            url: 'https://api.cd1a.cn/index.php/activity/Trans/recordslog',
            data: {
                userid_locked: uid
            },
            type: 'POST',
            dataType: 'json',
        }).then(res => {
            console.log(res)
            if(res.data.user_info.avatarUrl) {
                $('.user-img').attr('src', res.data.user_info.avatarUrl)
            }
            if(res.data.user_info.nickName) {
                $('.agent_name').html(res.data.user_info.nickName)
            }
            $('.rmb').html(res.data.user_info.money / 100)
            $('.rmb').data('money', res.data.user_info.money / 100)
            $('.id_num').html(res.data.user_info.id)
            if (res.code == 1) {
                // 循环渲染列表
                for (let i = 0; i < res.data.list.length; i++) {
                    let arr = '<div class="scroll-content">' +
                        '<div>' + res.data.list[i].pay_time + '</div>' +
                        '<div>' + res.data.list[i].project + '</div>' +
                        '<div>' + res.data.list[i].money + '</div>' +
                        '<div>' + res.data.list[i].status + '</div>' +
                        '</div>'
                    $('.scroll-div').append(arr)
                }
            } else if(res.code == 3) {
                return
            } else {
                info_alert(res.msg)
            }
        }).catch(err => {
            info_alert(err)
        })

        // 取消
        $('.cancel').click(() => {
            $('.mask').hide()
            $('.input_cash').hide()
            $('.money_input').val('')
        })

        // 提现
        $('.cash').click(() => {
            $('.mask').show()
            $('.input_cash').show()
        })

        // 确定
        $('.con_sure').click(() => {
            let value = $('.money_input').val()
            let money = $('.rmb').data('money')
            if (emotion.test(value)) {
                info_alert('不支持此类型内容')
            } else if(money == 0) {
                info_alert('暂无可提现金额')
            } else {
                $.ajax({
                    url: 'https://api.cd1a.cn/index.php/activity/Trans/With',
                    data: {
                        userid_locked: uid,
                        money: value * 100,
                    },
                    type: 'POST',
                    dataType: 'json',
                    success: function (res) {
                        console.log(res)
                        $('.money_input').val('')
                        $('.mask').hide()
                        $('.input_cash').hide()
                        if (res.code == 1) {
                            if (isWeiXin()) {
                                (function () {
                                    window.alert = function (name) {
                                        var iframe = document.createElement("IFRAME")
                                        iframe.style.display = "none"
                                        iframe.setAttribute("src", 'data:text/plain')
                                        document.documentElement.appendChild(iframe)
                                        window.frames[0].window.alert(name)
                                        iframe.parentNode.removeChild(iframe)
                                    }
                                })()
                                alert(res.msg)
                                location.reload()
                                return
                            }
                            if (isiOS) {
                                //ios
                                window.webkit.messageHandlers.showAlert.postMessage(res.msg)
                                location.reload()
                                return
                            }
                            if (isAndroid) {
                                //Android
                                window.TiantianCharge_Android.showAlert(res.msg)
                                location.reload()
                                return
                            }
                        } else {
                            info_alert(res.msg)
                        }
                    }
                })
            }
        })

        // 获取用户id
        function getUrldata(name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            let r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]);
            return null;
        }
    })
</script>

</html>